﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Transactions;
using Microsoft.Practices.EnterpriseLibrary.Logging;

using PostSharp.Laos;

using Arquitetura.Architectural.Model;

namespace Arquitetura.Architectural.Aspect
{
    public sealed class LoggingAttribute : OnMethodBoundaryAspect
    {
        #region Método(s)
        public override void OnEntry(MethodExecutionEventArgs eventArgs)
        {
        }

        public override void OnExit(MethodExecutionEventArgs eventArgs)
        {
            //eventArgs.

            if (eventArgs.Exception == null)
            {
                if (eventArgs.ReturnValue is Result)
                {
                    Result resultado = eventArgs.ReturnValue as Result;
                    if (resultado.Success)
                    {
                    }
                }
                else
                {
                }
            }
            else
            {
                Logger.Write(eventArgs.Exception);
            }
        }
        #endregion Método(s)
    }
}
